Telegram Group & Telegram Channel
143. Program to allocate memory using malloc() and free memory using free().

#include<stdio.h>
#include<stdlib.h>

int main() {

int n, i, *ptr, sum = 0;
printf("Enter total number of elements : ");
scanf("%d", &n);

ptr = (int *) malloc(n * sizeof(int));

if (ptr == NULL) {
printf("Error! Memory not allocated.");
return 0;
}

printf("Enter elements of array : \n");
for (i = 0; i < n; ++i) {
scanf("%d", ptr + i);
sum += *(ptr + i);
}

printf("Elements are :\n");
for (i = 0; i < n; i++) {
printf("%d\n", ptr[i]);
}

free(ptr);
return 0;
}
@C_Codings



tg-me.com/C_Codings/205
Create:
Last Update:

143. Program to allocate memory using malloc() and free memory using free().

#include<stdio.h>
#include<stdlib.h>

int main() {

int n, i, *ptr, sum = 0;
printf("Enter total number of elements : ");
scanf("%d", &n);

ptr = (int *) malloc(n * sizeof(int));

if (ptr == NULL) {
printf("Error! Memory not allocated.");
return 0;
}

printf("Enter elements of array : \n");
for (i = 0; i < n; ++i) {
scanf("%d", ptr + i);
sum += *(ptr + i);
}

printf("Elements are :\n");
for (i = 0; i < n; i++) {
printf("%d\n", ptr[i]);
}

free(ptr);
return 0;
}
@C_Codings

BY C Language πŸ‘¨β€πŸ’»


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/C_Codings/205

View MORE
Open in Telegram


C Language ‍ Telegram | DID YOU KNOW?

Date: |

However, analysts are positive on the stock now. β€œWe have seen a huge downside movement in the stock due to the central electricity regulatory commission’s (CERC) order that seems to be negative from 2014-15 onwards but we cannot take a linear negative view on the stock and further downside movement on the stock is unlikely. Currently stock is underpriced. Investors can bet on it for a longer horizon," said Vivek Gupta, director research at CapitalVia Global Research.

How To Find Channels On Telegram?

There are multiple ways you can search for Telegram channels. One of the methods is really logical and you should all know it by now. We’re talking about using Telegram’s native search option. Make sure to download Telegram from the official website or update it to the latest version, using this link. Once you’ve installed Telegram, you can simply open the app and use the search bar. Tap on the magnifier icon and search for a channel that might interest you (e.g. Marvel comics). Even though this is the easiest method for searching Telegram channels, it isn’t the best one. This method is limited because it shows you only a couple of results per search.

C Language ‍ from it


Telegram C Language πŸ‘¨β€πŸ’»
FROM USA